package edu.sdufe.map.TreeMap;



import java.util.TreeMap;

/**
 * @author wang'ji'cheng
 * @date 2025/7/26
 */
public class Demo3 {
    public static void main(String[] args) {

        String s = "aaadsakdakda";
        TreeMap<Character, Integer> treeMap = new TreeMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (treeMap.containsKey(c)) {
                Integer count = treeMap.get(c);
                count++;
                treeMap.put(c,count);
            }else{
                treeMap.put(c,1);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (Character c : treeMap.keySet()) {
            sb.append(c).append(" (").append(treeMap.get(c)).append(") ");
        }
        System.out.println(sb);

    }
}
